package com.sunshine.androidjavapractise.math;

import java.text.DecimalFormat;

public class MathClass {
    public static void main(String[] args) {
        double floatNumber1 = 11.555;
        double floatNumber2 = 11.545;

//        System.out.println(Math.round(floatNumber1));
//        System.out.println(Math.round(floatNumber2));
        System.out.println(String.format("%.2f", floatNumber1));
        System.out.println(String.format("%.2f", floatNumber2));
//        BigDecimal bigDecimal1 = new BigDecimal(11.555);
//        System.out.println(bigDecimal1.setScale(2, RoundingMode.HALF_EVEN).doubleValue());
//        BigDecimal bigDecimal2 = new BigDecimal(11.545);
//        System.out.println(bigDecimal2.setScale(2, RoundingMode.HALF_EVEN).doubleValue());
        DecimalFormat df = new DecimalFormat("0.0");
        System.out.println(df.format(floatNumber1));
        System.out.println(df.format(floatNumber2));
    }

}
